package ${serviceInfo.projectInfo.groupId}.controller.${urlPrefix};

import java.util.List;

import jakarta.validation.Valid;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.system.core.view.common.response.CommonDataResponse;
import com.system.core.view.common.response.CommonPageResponse;
import com.system.core.view.common.response.CommonResponse;

import ${serviceInfo.projectInfo.groupId}.dal.mybatis.model.${serviceInfo.modelName?cap_first};
import ${serviceInfo.serviceClazz?lower_case}.dto.${serviceInfo.serviceName?cap_first}AddReq;
import ${serviceInfo.serviceClazz?lower_case}.dto.${serviceInfo.serviceName?cap_first}UpdateReq;
import ${serviceInfo.projectInfo.groupId}.service.${serviceInfo.serviceName?lower_case}.${serviceInfo.serviceName?cap_first}Service;
import ${serviceInfo.projectInfo.groupId}.service.${serviceInfo.serviceName?lower_case}.dto.${serviceInfo.serviceName?cap_first}QueryFilter;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("${urlPrefix}/${baseUrl?replace("_","-")}")
@Tag(name = "${tableInfo.tableComment}管理(BOSS)")
@RequiredArgsConstructor
public class ${serviceInfo.serviceName?cap_first}BossController {
	<#list serviceInfo.columns as item>
	<#if item.prikey>
	<#assign priname="${item.javaCode?cap_first}"/>
	<#assign priType="${item.javaType}"/>
	</#if>
	</#list>
	
	private final ${serviceInfo.serviceName?cap_first}Service ${serviceInfo.serviceName?uncap_first}Service;
	
	@PostMapping(value = "${baseUrl?replace("_","-")}-list")
	@Operation(summary = "${tableInfo.tableComment}列表(BOSS)",description = "BOSS-${tableInfo.tableComment}列表")
	public CommonPageResponse<${serviceInfo.modelName?cap_first}> ${serviceInfo.serviceName?uncap_first}QueryList(@RequestBody ${serviceInfo.serviceName?cap_first}QueryFilter req) throws Exception{
		return ${serviceInfo.serviceName?uncap_first}Service.${serviceInfo.serviceName?uncap_first}List(req);
	}
	
	@GetMapping(value = "${baseUrl?replace("_","-")}-get")
	@Operation(summary = "${tableInfo.tableComment}详情(BOSS)",description = "BOSS-根据ID获取${tableInfo.tableComment}详情")
	public CommonDataResponse<${serviceInfo.modelName?cap_first}> ${serviceInfo.serviceName?uncap_first}GetByPrimaryKey(@RequestParam(required = true) ${priType} ${priname?uncap_first}){
		return ${serviceInfo.serviceName?uncap_first}Service.${serviceInfo.serviceName?uncap_first}GetByPrimaryKey(${priname?uncap_first});
	}
	
	@PostMapping(value = "${baseUrl?replace("_","-")}-add")
	@Operation(summary = "新增${tableInfo.tableComment}(BOSS)",description = "BOSS-新增${tableInfo.tableComment}")
	public CommonResponse ${serviceInfo.serviceName?uncap_first}Save(@RequestBody @Valid ${serviceInfo.serviceName?cap_first}AddReq req) {
		return ${serviceInfo.serviceName?uncap_first}Service.${serviceInfo.serviceName?uncap_first}Save(req);
	}
	
	@PostMapping(value = "${baseUrl?replace("_","-")}-edit")
	@Operation(summary = "编辑${tableInfo.tableComment}(BOSS)",description = "BOSS-编辑${tableInfo.tableComment}")
	public CommonResponse ${serviceInfo.serviceName?uncap_first}UpdateItem(@RequestBody @Valid ${serviceInfo.serviceName?cap_first}UpdateReq req) {
		return ${serviceInfo.serviceName?uncap_first}Service.${serviceInfo.serviceName?uncap_first}UpdateByPrimaryKey(req);
	}
	
	@PostMapping(value = "${baseUrl?replace("_","-")}-delete")
	@Operation(summary = "批量删除${tableInfo.tableComment}(BOSS)",description = "BOSS-批量删除${tableInfo.tableComment}")
	public CommonResponse ${serviceInfo.serviceName?uncap_first}DeleteItem(@RequestBody List<${priType}> keys) {
		return ${serviceInfo.serviceName?uncap_first}Service.${serviceInfo.serviceName?uncap_first}DeleteByPrimaryKey(keys);
	}
}
